Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use credentialed requests for password updates #200

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented Feb 21, 2023

Swap apiClient.put for makeCredentialHTTPRequest in auth.changePassword and auth.resetPassword.

This should allow those client methods to work even when the client and the API are not on the same origin eg. when using the staging API.

Closes #199.

I've set up zooniverse/Panoptes-Front-End#6436 to test this branch, so you can try out the changes on https://pr-6436.pfe-preview.zooniverse.org.

@eatyourgreens
Copy link
Contributor Author

eatyourgreens commented Feb 21, 2023

When I try to change my password on this branch, it still errors but now the error is a 405 response. The API doesn't allow PUT for cross-domain requests, it seems.

The HTTP 405 kittens from HTTP Cats
Here are the HTTP 405 kittens.

@eatyourgreens
Copy link
Contributor Author

I'm happy to leave this bug in the client for the time being, unless there's a burning need to get password reset working on staging.

Copy link
Contributor

@camallen camallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code now requests a PUT https://pr-6436.pfe-preview.zooniverse.org/users end point which isn't the API. This is a proxy to to the blob store and hence we get the x-ms-error-code | UnsupportedHttpVerb header response / 405 Method Not Allowed HTTP response.

The makeCredentialHTTPRequest needs to provide an API host and path URL to work correctly, not just a path.

Finally I don't think we need the credentialed request for password reset request but we most likely do for the others.

lib/auth.js Outdated Show resolved Hide resolved
lib/auth.js Outdated Show resolved Hide resolved
lib/auth.js Outdated Show resolved Hide resolved
@eatyourgreens
Copy link
Contributor Author

I've made those changes and updated the staging branch. Changing your password works now, even if you aren't on the same domain as the API.
https://pr-6436.pfe-preview.zooniverse.org/

Swap `apiClient.put` for `makeCredentialHTTPRequest` in `auth.changePassword` and `auth.resetPassword`.

This should allow those client methods to work even when the client and the API are not on the same origin eg. when using the staging API.
Copy link
Contributor

@yuenmichelle1 yuenmichelle1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eatyourgreens eatyourgreens merged commit 6e8b452 into master Feb 22, 2023
@eatyourgreens eatyourgreens deleted the credentialed-requests branch February 22, 2023 16:21
@eatyourgreens
Copy link
Contributor Author

I’ll get these changes out soonish as 5.2.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rails 6 Upgrade: Updating password from PFE mentions returns error that user is not signed in
3 participants